﻿Imports DataDynamics.ActiveReports
Imports DataDynamics.ActiveReports.Document
Imports System.Drawing
Imports Tohto.Base.ComUtility

Public Class RP0030R01

#Region "変数"

    ''' <summary>
    ''' ページフラグ
    ''' </summary>
    ''' <remarks></remarks>
    Private blnNewPage As Boolean = False

    Dim rowcounts As Integer = -1

    Dim rows As Integer = 0

#End Region

    Private Sub RP0030R01_ReportStart(sender As Object, e As System.EventArgs) Handles Me.ReportStart

        'Get the row number of the Data Source
        Dim dt As DataTable
        dt = Me.DataSource

        If rowcounts = 19 Then
            dt.Rows.Add()
            dt.Rows.Add()
            
            Me.DataSource = dt
        End If

        Dim rest As Integer = 0
        Dim rowtemp As Integer = rowcounts - 19
        rest = rowtemp Mod 39
        If rest = 0 Then
            dt.Rows.Add()
            dt.Rows.Add()

            Me.DataSource = dt
        End If

        '角印
        Dim shonin As String = CType(dt.Rows(0).Item("SHONIN_ST"), String)
        If shonin = CStr("02") Then
            Picture1.Visible = True
        Else
            Picture1.Visible = False

        End If

        'initialize the Total text box
        allTotal.Text = 0

        rowcounts = dt.Rows.Count

    End Sub

    Private Sub RP0030R01_PageStart(sender As Object, e As System.EventArgs) Handles Me.PageStart

        'set different heights for the last page (1.442/2.54) and the others(0.962/2.54)
        If rows > rowcounts - 39 Then
            PageFooter.Height = 1.442 / 2.54
        Else
            PageFooter.Height = 0.962 / 2.54
        End If

    End Sub

    Private Sub GroupHeader1_Format(sender As System.Object, e As System.EventArgs) Handles GroupHeader1.Format

        'page one does not show groupheader2
        blnNewPage = True

        Dim dtstring As String = txtMITUMORI_DT.Text
        dtstring = dtstring.Substring(0, 4).PadLeft(4, CChar("0")) & "年" & dtstring.Substring(5, 2).PadLeft(2, CChar("0")) & "月" & dtstring.Substring(8, 2).PadLeft(2, CChar("0")) & "日"
        txtMITUMORI_DT.Text = dtstring
        dtstring = txtKANRYO_YT_DT.Text
        dtstring = dtstring.Substring(0, 4).PadLeft(4, CChar("0")) & "年" & dtstring.Substring(5, 2).PadLeft(2, CChar("0")) & "月" & dtstring.Substring(8, 2).PadLeft(2, CChar("0")) & "日"
        txtKANRYO_YT_DT.Text = dtstring

    End Sub

    Private Sub GroupHeader2_Format(sender As System.Object, e As System.EventArgs) Handles GroupHeader2.Format

        If blnNewPage = True Then
            GroupHeader2.Height = 0
            blnNewPage = False
        End If
        Dim dtstring As String = txt2MITUMORI_DT.Text
        dtstring = dtstring.Substring(0, 4).PadLeft(4, CChar("0")) & "年" & dtstring.Substring(5, 2).PadLeft(2, CChar("0")) & "月" & dtstring.Substring(8, 2).PadLeft(2, CChar("0")) & "日"
        txt2MITUMORI_DT.Text = dtstring

    End Sub

    Private Sub RP0030R01_FetchData(sender As Object, eArgs As DataDynamics.ActiveReports.ActiveReport.FetchEventArgs) Handles Me.FetchData

        rows += 1

    End Sub

    Private Sub PageFooter_Format(sender As System.Object, e As System.EventArgs) Handles PageFooter.Format

        allTotal.Text = CDbl(TxtPageTotal.Text) + CDbl(PageTxtTotal.Text) + CDbl(allTotal.Text)
        TextBox32.Text = TextBox32.Text + "%"

    End Sub

    
End Class



